package com.kd.eb.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kd.eb.service.CategoryService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.Map;

@Controller
@RequestMapping("category")
public class CategoryController {

    @Resource
    private CategoryService categoryService;
    @RequestMapping("/small")
    public String SmallCategory(Model model,int cid,
                       @RequestParam(value = "psize",defaultValue = "1") int psize,
                       @RequestParam(value = "pageSize",defaultValue = "8") int pageSize) {

        System.out.println("接收到浏览器请求......");
        Map<String, Page> scResultMap = categoryService.sCategoryProduct(cid, psize, pageSize);
        model.addAttribute("scResultMap", scResultMap);

        return "product-list";
    }
}
